<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page import="com.cxl.entity.User" %><%--
  Created by IntelliJ IDEA.
  User: 20971
  Date: 2021/12/30
  Time: 14:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>视频文件上传</title>
    <link rel="stylesheet" href="resource/css/bootstrap.css">
    <script type="text/javascript" src="resource/js/jquery-3.2.1.js"></script>
</head>
<body>

<%
    User user = (User) request.getSession().getAttribute("LONGUSER");
%>
<h1 class="text-center">
    欢迎<%=user.getUsername()%>
    <c:if test="<%=user.getRole()==1%>">讲师</c:if>
    登陆到教育平台系统
</h1>

<form:form modelAttribute="c" action="getvideos" method="post" enctype="multipart/form-data">
    <table class="table table-hover">
        <tr>
            <td>课程名称</td>
            <td>
                <form:hidden path="cid"></form:hidden>
                <form:input path="cname"></form:input>
            </td>
        </tr>
        <tr>
            <td>课程视频</td>
            <td>
                <input type="text" name="video" id="video">
                <div id="toupvideo"></div>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="button" value="上传视频" onclick="tovideo2()">
            </td>
        </tr>
    </table>

</form:form>

<script>
    /*上传视频*/
    $("#toupvideo").load("mmcrofile/toup2");
    function uploadOk(fileNames){
        alert(fileNames);
        $("#video").val(fileNames);
    }

    /*发布*/
    function tovideo2() {
        $.post("getvideos",$("form").serialize(),function (msg) {
            if(msg){
                location.href = "list?role=<%=user.getRole()%>";
            }
        })
    }
</script>

</body>
</html>
